/**
 * Created by Abby on 2017/3/27.
 */
var myTime = function() {
    var d = new Date();//表明生成了一个日期对象
    var year = d.getFullYear();
    var month = d.getMonth();//从0开始
    var date = d.getDate();
    var week = d.getDay();
    switch (week) {
        case 0:
            week = "日";
            break;
        case 1:
            week = "一";
            break;
        case 2:
            week = "二";
            break;
        case 3:
            week = "三";
            break;
        case 4:
            week = "四";
            break;
        case 5:
            week = "五";
            break;
        case 6:
            week = "六";
            break;
        default:
            break;
    }
    var hour = d.getHours();
    var minute = d.getMinutes();
    var second = d.getSeconds();
    var ms = d.getMilliseconds();
    var pv = document.getElementById('p1');
    pv.textContent = '今天是 : 星期' + week + ' ' + year + '年' + (month + 1) + '月' + date + '日' + hour + ':' + minute + ':' + second;
};
   /* window.onload = function() {
    //setInterval 按照时间 间隔来循环执行
    //参数1: 脚本内容
    //参数2: 时间单位 (ms) 1000ms = 1s
    myTime();
    window.setInterval(myTime, 100);

};*/